package lab02.test33;

import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

/**
 * Created by lenovo on 2017/11/10.
 */
public class Test {
   public static void main(String[] args) {
       List<String> list = new ArrayList<String>();
       System.out.println("请输入若干个单词（以,隔开）：");
       Scanner in = new Scanner(System.in);
       String s = in.nextLine();
       String[] a = s.split(",");
       //s这个字符串用逗号“,”进行分割
       // 分割后的字符串数组放在a[]中
       for (int i = 0; i < a.length; i++) {
           for (int j = i + 1; j < a.length; j++) {
               if (a[i].compareToIgnoreCase(a[j]) > 0) {
                  s = a[i];     /**
                                *
                                *compareToIgnoreCase：比较，忽略大小写
                                *
                                *  */
                   a[i] = a[j];
                   a[j] = s;
               }
           }
       }
       for (String o : a) {
           list.add(o);
           System.out.println(o);//一个一个的把元素取出来,o就是你取出来的那个元素
       }
   }
}
